package com.njxzc.service.before;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njxzc.common.http.ResponseResult;
import com.njxzc.entity.FocusEntity;
import com.njxzc.mapper.before.FocusMapper;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Map;

@Service
public class FocusServiceImpl extends ServiceImpl<FocusMapper,FocusEntity> implements FocusService {
    @Override
    public ResponseResult<Map<String, Object>> addFocus(FocusEntity focusEntity) {
        Long count = lambdaQuery().eq(FocusEntity::getGoodstableId, focusEntity.getGoodstableId())
                .eq(FocusEntity::getBusertableId, focusEntity.getBusertableId()).count();
        if(count>0){
            return ResponseResult.getMessageResult(null,"A001");
        }
        focusEntity.setFocustime(new Date());
        if(save(focusEntity)){
            return ResponseResult.getMessageResult(null,"A002");
        }
        return ResponseResult.getMessageResult(null,"A003");
    }
}
